package com.cloud.rapid.screen.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloud.rapid.screen.dto.SysUserDTO;
import com.cloud.rapid.screen.entity.SysUser;
import com.cloud.rapid.screen.mapper.SysUserMapper;
import com.cloud.rapid.screen.service.SysUserService;
import com.cloud.rapid.screen.util.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户信息
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    /**
     * 列表查詢
     *
     * @param name 姓名
     * @return
     */
    @Override
    public List<SysUserDTO> listByQuery(String name) {
        LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(!StringUtils.isEmpty(name), SysUser::getName, name);
        List<SysUser> data = this.list(wrapper);
        return BeanUtils.convertProperties(data, SysUserDTO.class);
    }
}
